﻿using UnityEngine;
using System;
using System.Collections.Generic;

public class Regions {

	public short expansionWarId; 	// 진행중 확장전 지역아이디
	public short expansionWarStep; // 진행중 확장전 단계

	public int[] regionIds;

	[NonSerialized]
    List<Region> m_RegionMap = new List<Region>();
    public List<Region> regionList
    {
        get { return m_RegionMap; }
        set { m_RegionMap = value; SetDictionary(); }
    }

    void SetDictionary()
    {
        regionMap_Dic.Clear();
        foreach(Region temp in m_RegionMap)
        {
            regionMap_Dic.Add(temp.id.ToString(), temp);
        }
    }

    [NonSerialized]
	public Dictionary<string, Region> regionMap_Dic = new Dictionary<string, Region>();

	public bool isDispatchingMember(int memberId)
	{
		Debug.LogError(regionMap_Dic.Count);
		foreach(KeyValuePair<string, Region> pair in regionMap_Dic)
		{
			for(int i=0; i<pair.Value.dispatchMList.Length; i++)
			{
				Debug.LogError(pair.Value.dispatchMList[i] + " ----- " + memberId);
				if(pair.Value.dispatchMList[i] == memberId)
				{
					return true;
				}
			}
		}

		return false;
	}
}
